import React, { useEffect } from 'react';

const Consumlist = () => {
    let navigate = React.router.useNavigate();
    const [LoginUser, setLoginUser] = React.useState(React.$cookie.load('LoginUser') ?? {})
    const [consumlist, setConsumlist] = React.useState([])
    useEffect(() => {
        getConsumlist();
    }, [])

    const getConsumlist = async () => {
        let result = await React.$api.consum({
            busid: LoginUser.id
        })
        if (result.code == 1) {
            console.log(result.data)
            setConsumlist(result.data)
        }
    }
    return (
        <>
            <React.$vant.NavBar
                title="消费记录"
                leftText=""
                onClickLeft={() => navigate('/business/index')}
            />
            {
                consumlist.map((item) => {
                    return (
                        <div style={{ display: 'flex', justifyContent: 'space-around', borderTop:'1px solid #ccc', margin:'10px 0', padding:'10px 0' }}>
                            <div style={{width:'250px', font:'14px'}}>{item.content}</div>
                            <div style={{display:'flex', alignItems:'center'}}>{item.createtime}</div>
                        </div>
                    )
                })
            }

        </>
    )

}

export default Consumlist;